package menu;

import java.util.List;

/**
 * description:
 * array list菜单迭代器
 * @author Yuanml on 2020/10/25 11:01
 */
public class ArrayListMenuIterator implements Iterator {
    List<MenuItem> items;
    public ArrayListMenuIterator(List<MenuItem> items) {
        this.items = items;
    }

    /**
     * 游标，记录当前到哪个元素了
     */
    private int cursor = 0;
    @Override
    public boolean hasNext() {
        return cursor < items.size();
    }

    @Override
    public Object next() {
        return items.get(cursor++);
    }
}
